package org.ymh.unix_file_system.domain;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.ymh.unix_file_system.domain.DirNode;
import org.ymh.unix_file_system.domain.Foundation;
import org.ymh.unix_file_system.domain.INode;
import org.ymh.unix_file_system.domain.SuperBlock;

import java.util.HashMap;
import java.util.Stack;

/**
 * @description: 存放所有要用到的变量，并通过config来spring管理，全部共享同一个实例
 * @author lenovo
 * @date 2023/12/15 18:38
 * @version
 */
@Component
public class GlobalVariable {//

    @Autowired
    public Foundation foundation;//基本配置
    public SuperBlock superBlock;//超级块(STORE)
    public INode[] inodeArray;//存放inode节点，下标对应inode号(STORE)
    public DirNode rootDirNode;//根节点(STORE)
    public boolean[] blockBitMap;//块位图(STORE)
    public boolean[] inodeBitMap;//inode位图(STORE)
    public FreeBlockLinkedList rootStack;//成组链接根节点
    private String error;
    public Stack<VisitingRecordItem> visitingRecord;//访问记录
    public final INode rootInode=new INode((byte) 1);
    /**
    * @Description 序列化
    * @Author  lenovo
    * @Date   2023/12/15 21:50
    * @Param  给物理块号
    * @Return  返回给定数据类型
    * @Exception
    */
    public String getError()
    {
        String s=error;
        error=null;
        return s;
    }

    public void setError(String error) {
        this.error = error;
    }

    public Foundation getFoundation() {
        return foundation;
    }

    public void setFoundation(Foundation foundation) {
        this.foundation = foundation;
    }

    public INode[] getInodeArray() {
        return inodeArray;
    }

    public void setInodeArray(INode[] inodeArray) {
        this.inodeArray = inodeArray;
    }

    public DirNode getRootDirNode() {
        return rootDirNode;
    }

    public void setRootDirNode(DirNode rootDirNode) {
        this.rootDirNode = rootDirNode;
    }

    public boolean[] getBlockBitMap() {
        return blockBitMap;
    }

    public void setBlockBitMap(boolean[] blockBitMap) {
        this.blockBitMap = blockBitMap;
    }

    public boolean[] getInodeBitMap() {
        return inodeBitMap;
    }

    public void setInodeBitMap(boolean[] inodeBitMap) {
        this.inodeBitMap = inodeBitMap;
    }
}
